home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Technotools
/
Technotools (Chestnut CD-ROM)(1993).ISO
/
lang_c
/
cug106
/
charfun.asm
< prev
next >
Wrap
Assembly Source File
|
1984-06-14
|
8KB
|
346 lines
; charfun.asm
;
; Copyright (C) 1980, M J Maney
;
; First created 8/16/80
; Last revised 8/28/80 14:45
;
; Tested and installed 8/28/80 14:55
;
; This file contains the definitions for some character
; functions, written in assembler for compacteness and performance.
; The macros from the "crl.lib" file are used to create these
; functions in the BDS "crl" format with minimum pain.
;
maclib crl
;
;
BLANK equ 20H
TAB equ 09H
NEWLINE equ 0AH
;
;
; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;
; functions that operate on a byte and return
; a small integer or a character
;
; isalpha isupper islower isdigit
; isspace toupper tolower
;
; functions that operate on a pair of bytes and
; return an integer
;
; atob
;
; * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
;
;
PROC ISALPHA
lda ARG1
lxi h,0
cpi 'A'
rc ;less than 'A'
cpi 'z'+1
rnc ;greater than 'z'
inx h
cpi 'a'
rnc ;lower-case alpha, return TRUE
cpi 'Z'+1
rc ;upper-case alpha, return TRUE
dcx h
ret ;else return FALSE
PEND ISALPHA
;
;
PROC ISUPPER
lda ARG1
lxi h,0
cpi 'A'
rc ;less than 'A'
cpi 'Z'+1
rnc ;greater than 'Z'
inx h
ret ;else is upper-case
PEND ISUPPER
;
;
PROC ISLOWER
lda ARG1
lxi h,0
cpi 'a'
rc ;less than 'a'
cpi 'z'+1
rnc ;greater than 'z'
inx h
ret ;else is lower case
PEND ISLOWER
;
;
PROC ISDIGIT
lda ARG1
lxi h,0
cpi '0'
rc ;less than '0'
cpi '9'+1
rnc ;greater than '9'
inx h
ret ;else is decimal digit
PEND ISDIGIT
;
;
PROC ISSPACE
lda ARG1
lxi h,1
cpi BLANK
rz ;equals ' '
cpi TAB
rz ;equals tab
cpi NEWLINE
rz ;equals newline
dcx h
ret ;else is non-space
PEND ISSPACE
;
;
PROC TOUPPER
lda ARG1
mov l,a
mvi h,0 ;setup to return character unchanged
cpi 'a'
rc ;less than 'a'
cpi 'z'+1
rnc ;greater than 'z'
adi 'A'-'a' ;else is lower-case, convert it
mov l,a
ret
PEND TOUPPER
;
;
PROC TOLOWER
lda ARG1
mov l,a
mvi h,0 ;setup to return character unchanged
cpi 'A'
rc ;less than 'A'
cpi 'Z'+1
rnc ;greater than 'Z'
adi 'a'-'A' ;else is upper-case, convert it
mov l,a
ret
PEND TOLOWER
;
;
PROC ATOB
lda ARG1
sbi '0'
BC nogood ;illegal char below '0'
cpi 10
BC gotit ;character between '0' and '9'
sbi 'A' - '0'
BC nogood ;illegal char between '9' and 'A'
cpi 26
BC gotalph ;character between 'A' and 'Z'
sbi 'a' - 'A'
BC nogood ;illegal char between 'Z' and 'a'
cpi 26
BNC nogood ;illegal char above 'z'
gotalph:;have valid alpha, must be offset by 10
adi 10
gotit: ;have valid alpha-numeric char, converted value in A
lxi h,ARG2
cmp m
BNC nogood ;illegal char for specified base
mov l,a
mvi h,0
ret
;
nogood: ;illegal character or out of range for specified base
lxi h,-1
ret
PEND ATOB
;
;
end
/* csym.lib
Copyright (C) 1980, M J Maney
First created 3/1/80
Last revised 3/29/80 17:00
This file contains some basic definitions that will be needed, or
at least useful, to the majority of C programs. Some special
purpose libraries may assume that this library file is to be
included in a source file when they are to be used.
*/
/* Common symbolic constants */
#define TRUE 1
#define FALSE 0
#define YES 1 /* note YES is the same as TRUE, and NO is the same */
#define NO 0 /* as FALSE. Sometimes one is clearer than the other */
#define OK 1 /* again, the same as TRUE */
#define ERR -1 /* common, though not universal, signal of distress */
#define FF '\014'
#define NEWLINE '\n'
#define INFILE 0 /* symbols for open() in stdlib */
#define OUTFILE 1
#define IOFILE 2
#define DSKBUF 134 /* size of buffer needed for getc/putc */
#define IOBUFSIZ 134 /* same as DSKBUF, but I like this name better */
#define FNAMSIZ 16 /* can hold any legal filename with '\0' */
#define EOF -1 /* value getc returns on physical end of file */
#define EOT 0x1A /* value CP/M uses to delimit end of ascii files */
/* DANGER !! the next line contains a character that the Hazeltine
does not print, but regards as its 'lead-in', so this will look
sorta funny on the tube !!! ACT prints it ok */
#define #! ~ /* the C complement operator */
#define uint unsigned
/* Symbols used for stdlib files, collected togethere here to
ensure system concistency
*/
#define RAM 0
#define MAXLINE 132
#define NULL 0
/* I prefer the name NIL for a pointer to nothing */
#define NIL 0
/* Symbols for IO devices */
#define CONSOLE 1
#define PRINTER 2
#define READER 3
#define PUNCH 4
#define FILE 100
ret ;else is non-space
PEND ISSPACE
;
;
PROC TOUPPER
lda ARG1
mov l,a
mvi h,0 ;setup to return character unchanged
cpi 'a'
rc ;less than 'a'
cpi 'z'+1
rnc ;greater than 'z'
adi 'A'-'a' ;else is lower-case, convert it
mov l,a To incorporate the changes made by HRM in stdlib1.c
and stdlib2.c into deff.crl and deff2.crl for BDS C ver 1.31,
the following sequence of commands was executed.
note: comments are prefaced by "--"
-- eliminate old versions in deff and make room for new
clib
o 1 deff
d 1 getc
d 1 putc
d 1 fflush
d 1 sscanf
d 1 sprintf
d 1 _uspr
d 1 fgets
c 1 -- save version of deff with space available
^C -- reboot
-- add new versions (plus 1 new function) to deff
clib
o 1 deff
o 2 stdlib1
o 3 stdlib2
t 2 1 getc
t 2 1 putc
t 2 1 fflush
t 2 1 ungetc -- the new one
t 3 1 sscanf
t 3 1 sprintf
t 3 1 _uspr
t 3 1 fgets
c 1 -- permanentize it
^C -- reboot
-- add new routines to deff2
clib
o 1 deff2
o 2 stdlib2
t 2 1 lprintf
t 2 1 pprintf
t 2 1 lputs
t 2 1 pputs
t 2 1 rgets
t 2 1 lputc
t 2 1 pputc
t 2 1 rgetc
c 1 -- permanentize it
^C -- reboot
-- update process is complete
VOLUME CG6
DESCRIPTION:
NUMBER SIZE NAME COMMENTS
CATALOG.CG6 CONTENTS OF CP/M VOL. CG6
HISTORY.CG6 Credits for submissions.
CG6.1 1K BIOSLB.CRL A bios modified by Harvey Moran
CG6.2 4K BIOSLB.MAC
CG6.3 9K BIOSLB.PRN
CG6.4 8K BSPAT1-4.DOC More by Moran on bios tinkering.
CG6.5 3K CHARFUN.ASM Assembly version of library char
manipulation functions.
CG6.6 3K CRL.DOC Macro file to aid in generating
BDS compatible CRL files.
CG6.7 8K CRL.LIB
CG6.8 2K CSYM.LIB Symbol file for above.
CG6.9 1K DEFFMODS.HRM Narrative (tutorial) describing
The modification of Moran's standard
libraries. See STDLIB?.
CG6.10 1K FACT.MOU Factorial program written in MOUSE
CG6.13 13K GRAVT100.C Graphics for the VT100 in ANSI.
CG6.14 9K GRAVT100.CRL
CG6.15 3K IOFUN.ASM Assembly version of C i/o functions.
CG6.16 5K MACHINE.ASM Assembly crl functions, mostly
for manipulating blocks of memory
CG6.17 5K MOUSE.C Interpreter (originally in Pascal)
described in BYTE. Issue date in source
CG6.18 1K NTOI.C Small number crunching functions.
CG6.19 1K OTOI.C
CG6.20 4K PRVLIB.C Misc. functions.
CG6.21 5K QUEUE.C Functions to impliment FIFO's
By Scott Layson
CG6.22 1K STDEF.C Deff file for NTOI,OTOI,GRAVT100,
STRINGS, UTIL1.
CG6.23 4K STDIO.DOC Functions to simulate Unix's i/o
redirection. Written under 1.31 and
never tested in this form.
CG6.24 2K STDIO.LIB
CG6.25 5K STDIO.SRC
CG6.26 7K STDLIB1.C Modified libraries (for ver 1.32 of
BDS C) needed with Mouse, WP.C, XTRINS.
CG6.27 20K STDLIB2.C
CG6.28 4K STRFUN.ASM C string functions implemented in
assembly for efficiency.
CG6.29 5K STRINGS.C String manipulation package.
CG6.30 3K STRINGS.CRL
CG6.31 2K SYSTEM.C Deffs for files listed at STDEF.
CG6.32 1K TEST.MOU Test program for MOUSE...causes
a bug in this implementation to
show itself.
CG6.33 3K UTIL1.C Small functions by Donald Stevens.
CG6.34 1K XTRINSLB.CRL Two functions to manipulate bits
in